<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>辖区医疗废物处置方式统计表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        .laytable-cell-radio.layui-table-cell {
            padding: 0 5px 0 15px;
        }
        
        .laytable-cell-radio span {
            display: none;
        }
        
        .laytable-cell-radio .layui-form-radio {
            padding-right: 0;
            margin: 0;
        }
    </style>
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">统计日期</label>
            <div class="layui-inline" style="width: 200px;">
                <input type="text" class="layui-input" id="datetime" placeholder="请选择日期">
            </div>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serch" style="width: 90px;"><i class="layui-icon">&#xe615;</i>统计</button>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#datetime', //指定元素
                theme: '#1E9FFF',
                range: true,
                max: 0
            });
        });
        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;

            table.render({
                elem: '#demo',
                height: 'full-80',
                data: [],
                cols: [
                    [ //表头
                        {
                            field: 'type',
                            title: '处置方式',
                            width: "10%",
                            align: "center"
                        }, {

                            title: '全市',
                            width: "7%",
                            align: 'center',
                            templet: function(d) {
                                return (parseFloat(d.a) + parseFloat(d.b) + parseFloat(d.c) + parseFloat(d.d) + parseFloat(d.e) + parseFloat(d.f) + parseFloat(d.g) + parseFloat(d.h) + parseFloat(d.i) + parseFloat(d.j) + parseFloat(d.k) + parseFloat(d.l) + parseFloat(d.m)).toFixed(2);
                            }
                        }, {
                            field: 'a',
                            title: '上城区',
                            width: "7%",
                            align: "center",
                            templet: function(d) {
                                return d.a.toFixed(2)
                            }

                        }, {
                            field: 'b',
                            title: '下城区',
                            width: "7%",
                            align: "center",
                            templet: function(d) {
                                return d.b.toFixed(2)
                            }

                        }, {
                            field: 'c',
                            title: '江干区',
                            width: "7%",
                            align: "center",
                            templet: function(d) {
                                return d.c.toFixed(2)
                            }

                        }, {
                            field: 'd',
                            title: '拱墅区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.d.toFixed(2)
                            }

                        }, {
                            field: 'e',
                            title: '西湖区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.e.toFixed(2)
                            }

                        }, {
                            field: 'f',
                            title: '滨江区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.f.toFixed(2)
                            }

                        }, {
                            field: 'g',
                            title: '萧山区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.g.toFixed(2)
                            }

                        }, {
                            field: 'h',
                            title: '余杭区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.h.toFixed(2)
                            }

                        }, {
                            field: 'i',
                            title: '桐庐县',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.i.toFixed(2)
                            }

                        }, {
                            field: 'j',
                            title: '建德市',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.j.toFixed(2)
                            }

                        }, {
                            field: 'k',
                            title: '富阳区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.k.toFixed(2)
                            }

                        }, {
                            field: 'l',
                            title: '临安区',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.l.toFixed(2)
                            }

                        }, {
                            field: 'm',
                            title: '淳安县',
                            width: "6%",
                            align: "center",
                            templet: function(d) {
                                return d.m.toFixed(2)
                            }

                        }

                    ]
                ],
                skin: 'row', //表格风格				
                even: true,
            });
            $("#serch").on('click', function() {
                var tjson = [];
                $.ajax({
                    url: '../../../All/waycollect',
                    type: "post",
                    datatype: "json",
                    data: {
                        startdate: $("#datetime").val().split(" - ")[0],
                        enddate: $("#datetime").val().split(" - ")[1],
                    },
                    beforeSend: function(res) {
                        $("#serch").html('<i class="layui-icon">&#xe63d;</i>加载中');
                    },
                    success: function(res) {
                        tjson = [res.data[0]];
                        tjson.push({
                            type: '上送（小箱进大箱）',
                            a: 0,
                            b: 0,
                            c: 0,
                            d: 0,
                            e: 0,
                            f: 0,
                            g: 0,
                            h: 0,
                            i: 0,
                            j: 0,
                            k: 0,
                            l: 0,
                            m: 0,
                        })
                        tjson.push({
                            type: '自行处置',
                            a: 0,
                            b: 0,
                            c: 0,
                            d: 0,
                            e: 0,
                            f: 0,
                            g: 0,
                            h: 0,
                            i: 0,
                            j: 0,
                            k: 0,
                            l: 0,
                            m: 0,
                        })
                        tjson.push({
                            type: "合计",
                            a: tjson[0].a + tjson[1].a + tjson[2].a,
                            b: tjson[0].b + tjson[1].b + tjson[2].b,
                            c: tjson[0].c + tjson[1].c + tjson[2].c,
                            d: tjson[0].d + tjson[1].d + tjson[2].d,
                            e: tjson[0].e + tjson[1].e + tjson[2].e,
                            f: tjson[0].f + tjson[1].f + tjson[2].f,
                            g: tjson[0].g + tjson[1].g + tjson[2].g,
                            h: tjson[0].h + tjson[1].h + tjson[2].h,
                            i: tjson[0].i + tjson[1].i + tjson[2].i,
                            j: tjson[0].j + tjson[1].j + tjson[2].j,
                            k: tjson[0].k + tjson[1].k + tjson[2].k,
                            l: tjson[0].l + tjson[1].l + tjson[2].l,
                            m: tjson[0].m + tjson[1].m + tjson[2].m
                        })
                        table.reload('demo', {
                            data: tjson
                        })
                        $("table thead tr").css({
                            "background": "#1E9FFF",
                            "color": "white"
                        });
                    },
                    complete: function(XMLHttpRequest, textStatus) {

                        $("#serch").html('<i class="layui-icon">&#xe615;</i>统计');
                    },
                })


            });


            $("table thead tr").css({
                "background": "#1E9FFF",
                "color": "white"
            });

        });
    </script>
</body>

</html>